package com.example.demo.autoconfigure;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import io.seata.core.context.RootContext;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: user
 * @Description:
 * @Date: 2021/11/30
 */
@Configuration
public class FeignConfiguration implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        if (StringUtils.isNotEmpty(RootContext.getXID())) {
            template.header(RootContext.KEY_XID, RootContext.getXID());
        }
    }
}
